package com.liangwj.springbootdesignpatterns.structureTypePatterns.filter;

import java.util.List;

/**
 * <b>Description:</b> and标准的实体类实现接口 <br/>
 * @author Lingwenjun
 * @date 2019/1/24-17:00
 * @version 1.0
 */
public class AndCriteria implements Criteria{

    private Criteria criteria;

    private Criteria otherCriteria;

    public AndCriteria(Criteria criteria, Criteria otherCriteria) {
        this.criteria = criteria;
        this.otherCriteria = otherCriteria;
    }

    @Override
    public List<Person> meetCriteria(List<Person> persons) {
        //过滤2次,剩下的是都符合过滤条件的
        List<Person> firstCriteriaPerson = criteria.meetCriteria(persons);
        return otherCriteria.meetCriteria(firstCriteriaPerson);
    }
}
